package com.businesswebsite.businesswebsite.FormalWebExplot.Service.impl.Event;

import com.businesswebsite.businesswebsite.FormalWebExplot.Dao.HotEvent.HotEventDao;
import com.businesswebsite.businesswebsite.FormalWebExplot.Entity.HotEvent;
import com.businesswebsite.businesswebsite.FormalWebExplot.Service.Event.HotEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class HotEventServiceImpl implements HotEventService {
    @Autowired
    HotEventDao hotEventDao;

    @Override
    public List<HotEvent> getHotEvent() throws Exception {
        List<HotEvent> event = hotEventDao.getHotEvent();
        if (event.size() > 0) {
            return event;
        } else {
            throw new Exception("请求数据失败");
        }
    }

    @Override
    public Integer addHotEvent(Map<String, Object> params) throws Exception {
        System.out.println(params.get("event_id"));
        if (params.get("event_id").toString() != null){
            Integer result = hotEventDao.addHotEvent(params);
            return result;
        }else{
            throw new Exception("新增数据失败");
        }
    }

    @Override
    public Boolean delHotEvent(String id) {
        if(id != null){
            Boolean del = hotEventDao.delHotEvent(id);
            if(del){
                return del;
            }else{
                return false;
            }
        }
        return null;
    }

}
